import { BaseException } from './base.exception';

/**
 * 业务异常类
 * 对应 Java: BusinessException
 */
export class BusinessException extends BaseException {
  constructor(
    message: string,
    errorCode: string = 'BUSINESS_ERROR',
    details?: any,
  ) {
    super(message, 400, errorCode, details);
  }
}

/**
 * 认证异常类
 * 对应 Java: AuthException
 */
export class AuthException extends BaseException {
  constructor(message: string = '认证失败', details?: any) {
    super(message, 401, 'AUTH_ERROR', details);
  }
}

/**
 * 授权异常类
 * 对应 Java: AuthorizationException
 */
export class AuthorizationException extends BaseException {
  constructor(message: string = '权限不足', details?: any) {
    super(message, 403, 'AUTHORIZATION_ERROR', details);
  }
}

/**
 * 资源未找到异常类
 * 对应 Java: ResourceNotFoundException
 */
export class ResourceNotFoundException extends BaseException {
  constructor(message: string = '资源未找到', details?: any) {
    super(message, 404, 'RESOURCE_NOT_FOUND', details);
  }
}

/**
 * 参数验证异常类
 * 对应 Java: ValidationException
 */
export class ValidationException extends BaseException {
  constructor(message: string = '参数验证失败', details?: any) {
    super(message, 422, 'VALIDATION_ERROR', details);
  }
}

/**
 * 冲突异常类
 * 对应 Java: ConflictException
 */
export class ConflictException extends BaseException {
  constructor(message: string = '资源冲突', details?: any) {
    super(message, 409, 'CONFLICT_ERROR', details);
  }
}

/**
 * 限流异常类
 * 对应 Java: RateLimitException
 */
export class RateLimitException extends BaseException {
  constructor(message: string = '请求过于频繁', details?: any) {
    super(message, 429, 'RATE_LIMIT_ERROR', details);
  }
}

/**
 * 系统异常类
 * 对应 Java: SystemException
 */
export class SystemException extends BaseException {
  constructor(message: string = '系统内部错误', details?: any) {
    super(message, 500, 'SYSTEM_ERROR', details);
  }
}

/**
 * 数据库异常类
 * 对应 Java: DatabaseException
 */
export class DatabaseException extends BaseException {
  constructor(message: string = '数据库操作失败', details?: any) {
    super(message, 500, 'DATABASE_ERROR', details);
  }
}

/**
 * 网络异常类
 * 对应 Java: NetworkException
 */
export class NetworkException extends BaseException {
  constructor(message: string = '网络连接失败', details?: any) {
    super(message, 503, 'NETWORK_ERROR', details);
  }
}
